package io.github.bigbird0101.datatransfer.container;

import lombok.Setter;
import org.apache.commons.lang.Validate;

/**
 * 执行容器的抽象类，持有该容器全局的配置 configuration
 */
@Setter
public abstract class AbstractContainer {

    protected String configuration;

    public AbstractContainer() {
    }

    public AbstractContainer(String configuration) {
        Validate.notNull(configuration, "Configuration can not be null.");
        this.configuration = configuration;
    }

    public String getConfiguration() {
        return configuration;
    }

    public abstract void start();

    public abstract void sendData(String data);

    /**
     * 停止，先关闭读，等待通道内数据写完，再停止写线程
     */
    public abstract void stop();

    /**
     * 强行停止，会丢失正在写的数据
     */
    public abstract void shutdown();
}
